package byggeTegning.geometry;

import javax.media.j3d.*;
import javax.vecmath.*;

public class Line3D extends Shape3D
{
  public static final Color3f red = new Color3f(1.0f,0.0f,0.0f);
  public static final Color3f green = new Color3f(0.0f,1.0f,0.0f);
  public static final Color3f blue = new Color3f(0.0f,0.0f,1.0f);
  public static final Color3f yellow = new Color3f(1.0f,1.0f,0.0f);
  public static final Color3f cyan = new Color3f(0.0f,1.0f,1.0f);
  public static final Color3f magenta = new Color3f(1.0f,0.0f,1.0f);
  public static final Color3f white = new Color3f(1.0f,1.0f,1.0f);
  public static final Color3f black = new Color3f(0.0f,0.0f,0.0f);

  
  public Line3D(Point3f p0,Point3f p1)
  { addGeometry(line3D(p0,p1,white,white)); }

  public Line3D(Point3f p0,Point3f p1,Color3f c)
  { addGeometry(line3D(p0,p1,c,c)); }

  public Line3D(Point3f p0,Point3f p1,Color3f c0,Color3f c1)
  { addGeometry(line3D(p0,p1,c0,c1)); }
  
  static void addAxis3D(Group group,Color3f c)
  {
    group.addChild(new Line3D(new Point3f(-1.0f,0.0f,0.0f),
                              new Point3f(+1.0f,0.0f,0.0f),c));
    group.addChild(new Line3D(new Point3f(0.0f,-1.0f,0.0f),
                              new Point3f(0.0f,+1.0f,0.0f),c));
    group.addChild(new Line3D(new Point3f(0.0f,0.0f,-1.0f),
                              new Point3f(0.0f,0.0f,+1.0f),c));
  }  
  
  private LineArray line3D(Point3f p0,Point3f p1,Color3f c0,Color3f c1)
  { LineArray lines=new LineArray(2,LineArray.COORDINATES
                                   |LineArray.COLOR_3);
    lines.setCoordinate(0,p0);
    lines.setCoordinate(1,p1);
    lines.setColor(0,c0);//green);
    lines.setColor(1,c1);//blue);
    return(lines);
  }  
}
